package com.todolist.service.impl;

import com.todolist.dao.TTodolist;
import com.todolist.mapper.TTodolistMapper;
import com.todolist.service.ToDOListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ToDoListServiceImpl implements ToDOListService {

    @Autowired
    TTodolistMapper todolistMapper;
    /**
     * 根据用户名获取代办列表
     * @param name
     * @return
     */
    public List<TTodolist> getListByName(String name) {

        List<TTodolist> byUsername = todolistMapper.getByUsername(name);
        return byUsername;

    }

    /**
     * 根据当前事项id去设置事项状态
     * @param todolist
     */
    public void setStatusByID(TTodolist todolist) {
        todolistMapper.setStatusByID(todolist);
    }

    /**
     * 根据事项id去删除事项
     * @param id
     */
    public void delToDoById(int id) {
        todolistMapper.deleteToDoById(id);
    }

    /**
     * 清除已完成的事项
     * @param
     */
    public void delAllDoByUsername(String username) {
        todolistMapper.deleteDoByusername(username);
    }
}
